package com.kehutong.material.admin;

import com.kehutong.material.entity.WelCome;
import com.kehutong.material.service.impl.WelcomeServiceImpl;
import org.coraframework.authz.HasPermission;
import org.coraframework.inject.Inject;
import org.coraframework.json.JSONObject;
import org.coraframework.mvc.MvcAction;
import org.coraframework.mvc.http.Bean;
import org.coraframework.mvc.http.ReqMapping;
import org.coraframework.mvc.http.result.Result;
import org.coraframework.orm.jdbc.Page;

import java.io.IOException;
/**
 * 欢迎语控制器
 * @author: liukunlong
 * @date: 2021-02-19 15:12
 */
@MvcAction
@ReqMapping("/admin/crm/welcome")
public class WelcomeController {
	
	@Inject
	private WelcomeServiceImpl welcomeService;

	@HasPermission("crm:welcome:view")
	@ReqMapping("/list")
	public Object list(JSONObject jsonObject) throws IOException {
		Page<WelCome> page = welcomeService.list(jsonObject);
		
		return Result.success(page);
	}

	@HasPermission("crm:welcome:view")
	@ReqMapping("/get")
	public Object get(String id) {
		WelCome welcome = welcomeService.get(id);
		
		return Result.success(welcome);
	}

	@Bean(newInstance=true, copy=true)
	@HasPermission("crm:welcome:edit")
	@ReqMapping("/save")
	public Object save(WelCome welcome, JSONObject jsonObject) throws IOException {
		return welcomeService.save(welcome, jsonObject);
	}

	@Bean(copy=true)
	@HasPermission("crm:welcome:edit")
	@ReqMapping("/update")
	public Object update(WelCome welcome, JSONObject jsonObject) throws IOException {
		return welcomeService.update(welcome, jsonObject);
	}

	@HasPermission("crm:welcome:edit")
	@ReqMapping("/delete")
	public Object delete(String id) throws IOException {
		return welcomeService.delete(id);
	}
}
